import type {
  Codetye,
  Patient,
  PatientList,
  User,
  UserInfo
} from '@/types/user'
import { request } from '@/utils/request'

//密码登录
const loginByPassword = (mobile: string, password: string) =>
  request<User>('login/password', 'POST', { mobile, password })

//获取验证码
const sendMobileCode = (mobile: string, type: Codetye) =>
  request('code', 'GET', { mobile, type })

//短信登录
const loginByMobile = (mobile: string, code: string) =>
  request<User>('login', 'post', { mobile, code })

//获取用户信息
const getUserInfo = () => request<UserInfo>('patient/myUser')

//获取患者列表
const getPatientList = () => request<PatientList>('patient/mylist')

//添加患者
const addPatientUser = (patient: Patient) =>
  request('patient/add', 'post', patient)

//编辑患者
const editPatient = (patient: Patient) =>
  request('patient/update', 'put', patient)

//删除患者
const delPatient = (id: string) => request(`patient/del/${id}`, 'delete')

//获取未读消息数量
const getUnReadMessageCount = () =>
  request<number>('patient/message/unRead/all')

export {
  loginByPassword,
  sendMobileCode,
  loginByMobile,
  getUserInfo,
  getPatientList,
  addPatientUser,
  editPatient,
  delPatient,
  getUnReadMessageCount
}
